#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(){
    stack<char> st;
    string s;
    cout << "Enter your bracket sequence: ";
    cin >> s;
    for (int i = 0; i < s.size(); ++i){
        if (s[i] == '(' or s[i] == '[' or s[i] == '{' or s[i] == '<'){
            st.push(s[i]);
            
        }
        else{
            if (!st.empty()){
                char simb = st.top();
                if ((s[i] == ')' and simb== '(') or (s[i] == ']' and simb== '[') or (s[i] == '}' and simb== '{') or (s[i] == '>' and simb== '<')){
                    st.pop();
                }
                else{
                    cout << "False";
                    return 0;
                }
            }
            
            else{
                
                cout << "False";
                return 0;
            }
        }
    }
    if (!st.empty() == 0){
        cout << "True";
       return 0;
    }
    
    cout << "False";
    return 0;
}